{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "30407d72-0cdf-4306-b7c4-df3b01a82eb2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[3 2 1]\n",
      " [5 4 1]\n",
      " [1 7 9]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "a = np.array([3,1,2])\n",
    "b = np.array([5,1,4])\n",
    "c = np.array([1,9,7])\n",
    "indices = np.lexsort((a,b,c)) #c数组记录各个数的顺序(0,1,2),由小到大排序后,变为(0,2,1)\n",
    "#a,b数组按照变化后的c数组的顺序(0,2,1)排列\n",
    "sorted = np.vstack((a[indices],b[indices],c[indices]))\n",
    "print(sorted)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ed693741-a5b1-4dcc-a2ab-7b08a783641b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
